package com.weishi.pay.dao;


import com.weishi.frame.common.utils.MybatisGeneratorUtil;
import com.weishi.frame.common.utils.PropertiesFileUtil;

import java.util.HashMap;
import java.util.Map;

/**
 * 代码生成类
 * Created by ZhangShuzheng on 2017/1/10.
 * @author autoCode
 */
public class Generator {

    // 根据命名规范，只修改此常量值即可

    /**
     * 模块名
     */
    private static String MODULE = "Pay";

    /**
     * 数据库名
     */
    private static String DATABASE = "center_manage";

    /**
     * 生成POJO时需要裁剪的前缀
     * 例如：
     * talbe_name = t_b_user
     * table_prefix = "t_"
     * 则自动生成的POJO为 bUser
     */
    private static String TABLE_PREFIX = "tbl_";
//    /**
//     * 需要自动生成的表名，支持前模糊查询
//     */
    public static final String TABLE_NAME = "tbl_";

    /**
     * 包名
     */
    private static String PACKAGE_NAME = "com.weishi.pay";


    private static String JDBC_DRIVER = PropertiesFileUtil.getInstance("generator").get("generator.jdbc.driver");
    private static String JDBC_URL = PropertiesFileUtil.getInstance("generator").get("generator.jdbc.url");
    private static String JDBC_USERNAME = PropertiesFileUtil.getInstance("generator").get("generator.jdbc.username");
    private static String JDBC_PASSWORD = PropertiesFileUtil.getInstance("generator").get("generator.jdbc.password");
    /**
     * 需要insert后返回主键的表配置，key:表名,value:主键名
     */
    private static Map<String, String> LAST_INSERT_ID_TABLES = new HashMap<>();

    static {
//        LAST_INSERT_ID_TABLES.put("tbl_brand", "brandId");
//        LAST_INSERT_ID_TABLES.put("tbl_product", "productId");
//        LAST_INSERT_ID_TABLES.put("tbl_product_category", "categoryId");
//        LAST_INSERT_ID_TABLES.put("tbl_product_category_brand_relation", "relationId");
//        LAST_INSERT_ID_TABLES.put("tbl_product_parameter", "parameterId");
//        LAST_INSERT_ID_TABLES.put("tbl_product_tag", "tagId");
//        LAST_INSERT_ID_TABLES.put("tbl_product_tag_relation", "relationId");
//        LAST_INSERT_ID_TABLES.put("tbl_sku", "skuId");
//        LAST_INSERT_ID_TABLES.put("tbl_product_specification", "specificationd");
//        LAST_INSERT_ID_TABLES.put("tbl_stock_log", "logId");
       // LAST_INSERT_ID_TABLES.put("tbl_payment", "id");

    }

    /**
     * 自动代码生成
     */
    public static void main(String[] args) throws Exception {
        MybatisGeneratorUtil.generator(JDBC_DRIVER, JDBC_URL, JDBC_USERNAME, JDBC_PASSWORD, MODULE, DATABASE,
                TABLE_PREFIX, TABLE_NAME, PACKAGE_NAME, LAST_INSERT_ID_TABLES);
    }

}
